import React from 'react';
import { Modal } from 'ywen-mobile-ui';
import PropTypes from 'prop-types';
import BaseComponent from '../../components/common/baseComponent.js';
import warnIcon from '../../../assets/images/coupon/warn.png';


class CouponAlert extends BaseComponent {
  static propTypes = {
    closeFunc: PropTypes.func.isRequired,
  }
  state = {
    show: false,
    text: '',
  }

  show = (text) => {
    this.setState({ show: true, text });
  }

  close = () => {
    this.setState({ show: false });
  }
  render() {
    const { show, text } = this.state;
    if (!show) {
      return null;
    }
    const { closeFunc } = this.props;
    return (
      <Modal className="coupon-alert-modal">
        <div className="content">
          <img src={warnIcon} className="icon" alt="" />
          <p className="text">{text}</p>
          <div className="btn-view">
            <div className="action-btn cancel" onClick={this.close}><div>取消</div></div>
            <div className="action-btn" onClick={closeFunc}><div>确定</div></div>
          </div>

        </div>
      </Modal>
    );
  }
}

export default CouponAlert;
